package main

import (
	"quiz/common"
	"quiz/conf"
	"quiz/models"
	_ "quiz/routers"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	orm.RegisterDataBase("default", "mysql", beego.AppConfig.String("sqlconn"))
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
	}
	conf.InitRedis()
	defer common.Rdb.Close()
	// init global cache
	conf.InitCache()
	models.InitToken()
	beego.Run()
}
